namespace Collaboris.Saf.Actions.Wss.Tests.Generated
{
    using Engine.Report;

    using Microsoft.SharePoint;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Saf.Tests;
    using Entities;

    using SharePoint.Wss.Sites;

    using Utils;

    using Wss.Site;

    /// <summary>
    /// This test was originally generated but has now been tested and verfiied by MJ
    /// </summary>
    [TestClass]
    public class CreateSiteTest
    {
        [TestMethod]
        public void CreateSite_Test()
        {
            WSSTestAssistant<CreateSite, SiteInfo> createsite =
                    new WSSTestAssistant<CreateSite, SiteInfo>(TestEnvironment.PublishingSite, 
                        "CreateSiteTestWeb", "BLANKINTERNET#0");

            using (createsite)
            {
                MacroReport doReport = createsite.DoMacro();

                Assert.IsTrue(
                    SPSiteHelper.SiteExists(
                        UriHelper.Combine(createsite.FirstEntity.WebApplicationUrl , createsite.FirstEntity.SiteCollectionUrl)));

                MacroReport undoReport = createsite.UndoMacro();

                Assert.IsFalse(
                    SPSiteHelper.SiteExists(
                        UriHelper.Combine(createsite.FirstEntity.WebApplicationUrl, createsite.FirstEntity.SiteCollectionUrl)));
            }
        }

        [TestMethod]
        public void CreateSite_NoSecondary_Test()
        {
            WSSTestAssistant<CreateSite, SiteInfo> createsite =
                    new WSSTestAssistant<CreateSite, SiteInfo>(TestEnvironment.PublishingSite,
                        "CreateSiteTestWeb", "BLANKINTERNET#0");

            using (createsite)
            {
                // lets change the Entity in place now and see if that works!
                createsite.FirstEntity.SecondaryContactLogin = string.Empty;

                MacroReport doReport = createsite.DoMacro();

                Assert.IsTrue(
                    SPSiteHelper.SiteExists(
                        UriHelper.Combine(createsite.FirstEntity.WebApplicationUrl, createsite.FirstEntity.SiteCollectionUrl)));

                using (SPSite site = SPSiteHelper.GetSite(
                   UriHelper.Combine(
                       createsite.FirstEntity.WebApplicationUrl, createsite.FirstEntity.SiteCollectionUrl)))
                {
                    Assert.IsNull(site.SecondaryContact);
                }

                MacroReport undoReport = createsite.UndoMacro();

                Assert.IsFalse(
                    SPSiteHelper.SiteExists(
                        UriHelper.Combine(createsite.FirstEntity.WebApplicationUrl, createsite.FirstEntity.SiteCollectionUrl)));

               
            }
        }

    }
}
